package com.mcptt.config.body;

import android.util.Xml;

import com.cloudptt.api.product.log.Log;
import com.mcptt.config.body.pidf.PidfXmlBody;

import org.xmlpull.v1.XmlPullParser;

import java.io.ByteArrayInputStream;
import java.util.List;
import java.util.Vector;

public class SubscribeErrXml {
//	private static final String End_Mcptt_Tag = "</IN_XML>";
	private static final String Name_Msg = "Msg";
	private static final String Name_Cause = "Cause";
	private static final String Name_McIds = "Msg";
	private static final String Name_McId = "Cause";
//	private static final String Name_TriggerId = "TriggerId";

	private String msg = null;



	private String cause = null;

	public SubscribeErrXml()
	{
	}


	public static SubscribeErrXml parseXmlStr(String xmlStr)
	{
		SubscribeErrXml body = new SubscribeErrXml();

		ByteArrayInputStream strIs = new  ByteArrayInputStream(xmlStr.getBytes());
		XmlPullParser pullParser = Xml.newPullParser();
		try {
			pullParser.setInput(strIs, "UTF-8"); //为Pull解释器设置要解析的XML数据
			int event = pullParser.getEventType();

			while (event != XmlPullParser.END_DOCUMENT){

				switch (event) {

					case XmlPullParser.START_DOCUMENT:
						break;
					case XmlPullParser.START_TAG:
						if (Name_Msg.equals(pullParser.getName()))
						{
							body.msg = pullParser.nextText();
						}
						else if (Name_Cause.equals(pullParser.getName()))
						{
							body.cause = pullParser.nextText();
						}
						break;
					case XmlPullParser.END_TAG:
						break;

				}

				event = pullParser.next();
			}

		}
		catch (Exception e)
		{
			e.printStackTrace();
		}

		return body;
	}

	public String getMsg() {
		return msg;
	}
	public String getCause() {
		return cause;
	}

	public String toString()
	{
		StringBuffer strBuff = new StringBuffer();
		strBuff.append("msg = ").append(msg).append(",");
		strBuff.append("cause = ").append(cause).append(".");

		return strBuff.toString();
	}
}
